package com.paradise.phone.utils;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;

/**
 * Created by Sisyphus on 2017/4/7.
 */

public class ItemSlide extends HorizontalScrollView {

    private View vContent; // 显示内容部分视图
    private View vHide; // 隐藏部分视图

    private float downY;
    private float moveY;

    public ItemSlide(Context context) {
        super(context);
    }

    public ItemSlide(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        ViewGroup root = (ViewGroup) getChildAt(0);
        vContent = root.getChildAt(0);
        vHide = root.getChildAt(1);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {

        switch (ev.getAction()){
            case MotionEvent.ACTION_DOWN:
                downY = ev.getY();
                break;
            case MotionEvent.ACTION_MOVE:
                moveY = ev.getY();

                if (moveY - downY < 15){
                    return true;
                }

                break;
        }

        return false;
    }
}
